const webSocketServer = require('ws').Server;

const server = new webSocketServer({ port: 8001 });

const date = new Date();

server.on('connection', (client) => {
  const data = {
    event: 'connect',
    data: date.getTime().toString(),
  };
  client.send(JSON.stringify(data));
  console.log('hello world');
});

server.on('message', (data) => {
  server.clients.forEach((client) => {
    client.send(data);
  });
});
